<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>首页</title>
    <link href="css/home-page.css" rel="stylesheet">
    <link href="css/imgs.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
  </head>
  
  <body>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js" integrity="sha384-/mhDoLbDldZc3qpsJHpLogda//BVZbgYuw6kof4u2FrCedxOtgRZDTHgHUhOCVim" crossorigin="anonymous"></script>
    
    <nav class="navbar navbar-expand-lg bg-body-tertiary">
      <div class="container-fluid">
        <a class="navbar-brand" href="/request-demo/selectAllServlet">电商平台</a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
          <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarNav">
          <ul class="navbar-nav">
            <li class="nav-item">
              <a class="nav-link active" aria-current="page" href="/request-demo/selectAllServlet">首页</a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="/request-demo/viewProfileServlet">${user.username}</a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="/request-demo/shoppingCartSelectServlet"><img src="imgs/shopping-cart.webp" class="shopping-cart-img">购物车</a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="/request-demo/myStoreServlet"><img src="imgs/shop-logo.webp" class="shop-logo">我的店铺</a>
            </li>
          </ul>
        </div>
      </div>
    </nav>
      
    <!-- <div class="top-blank">
      <a href="/request-demo/selectAllServlet">首页</a>
      <p class="username">Hi！<a href="/request-demo/viewProfileServlet">${user.username}</a></p>
      <a href="/request-demo/shoppingCartSelectServlet"><img src="imgs/shopping-cart.webp" class="shopping-cart-img">购物车</p>
      <a href="/request-demo/myStoreServlet"><img src="imgs/shop-logo.webp" class="shop-img">我的店铺</p>
    </div> -->

    <!-- <div class="container text-center">
      <div class="row g-5">
        <c:forEach items="${items}" var="item" varStatus="status">
          <div class="col-4">
            <div class="p-3">
              <a href="/request-demo/itemDetailServlet?id=${item.id}" class="item-link">
                <div class="card" style="width: 18rem;">
                  <img src="imgs/item.jpg" class="card-img-top square-img" alt="item image">
                  <div class="card-body">
                    <h5 class="card-title">${item.itemName}</h5>
                    <p class="card-text">¥${item.price}</p>
                  </div>
                </div>
              </a>
            </div>
          </div>
        </c:forEach>
      </div>
    </div> -->

    <!-- <div class="container">
      <div class="row row-cols-1 row-cols-md-3 g-4">
        <c:forEach items="${items}" var="item" varStatus="status">
          <div class="col">
            <div class="card mb-3" style="max-width: 540px;">
              <div class="row g-0">
                <div class="col-md-4">
                  <img src="..." class="img-fluid rounded-start" alt="...">
                </div>
                <div class="col-md-8">
                  <div class="card-body">
                    <h5 class="card-title">Card title</h5>
                    <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
                    <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </c:forEach>
      </div>
    </div> -->

    <c:if test="${loggedIn}">
      <div class="container">
        <h3>为您推荐</h3>
        <div class="row row-cols-1 row-cols-md-3 g-4">
          <c:forEach items="${recommendedItems}" var="recommendedItem" varStatus="status">
            <a href="/request-demo/itemDetailServlet?id=${recommendedItem.id}" class="item-link">
              <div class="col">
                <div class="card mb-3 h-100" style="max-width: 540px;">
                  <div class="row g-0">
                    <div class="col-md-4">
                      <img src="imgs/item.jpg" class="img-fluid rounded-start" alt="item image">
                    </div>
                    <div class="col-md-8">
                      <div class="card-body">
                        <h5 class="card-title">${recommendedItem.itemName}</h5>
                        <p class="card-text"><small class="text-muted">${recommendedItem.description}</small></p>
                        <p class="card-text">¥${recommendedItem.price}</p>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </a>
          </c:forEach>
        </div>
      </div>
  
      <!-- 用于空行 -->
      <div style="height: 50px;"></div>
    </c:if>

    <div class="container">
      <h3>所有商品</h3>
      <div class="row row-cols-1 row-cols-md-3 g-4">
        <c:forEach items="${items}" var="item" varStatus="status">
          <a href="/request-demo/itemDetailServlet?id=${item.id}" class="item-link">
            <div class="col">
              <div class="card mb-3 h-100" style="max-width: 540px;">
                <div class="row g-0">
                  <div class="col-md-4">
                    <img src="imgs/item.jpg" class="img-fluid rounded-start" alt="item image">
                  </div>
                  <div class="col-md-8">
                    <div class="card-body">
                      <h5 class="card-title">${item.itemName}</h5>
                      <p class="card-text"><small class="text-muted">${item.description}</small></p>
                      <p class="card-text">¥${item.price}</p>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </a>
        </c:forEach>
      </div>
    </div>

    <!-- <div class="row row-cols-1 row-cols-md-3 g-4">
      <c:forEach items="${items}" var="item" varStatus="status">
        <a href="/request-demo/itemDetailServlet?id=${item.id}" class="item-link">
          <div class="col">
            <div class="card mb-3 h-100" style="max-width: 540px;">
              <div class="row g-0">
                <div class="col-md-4">
                  <img src="imgs/item.jpg" class="img-fluid rounded-start" alt="item image">
                </div>
                <div class="col-md-8">
                  <div class="card-body">
                    <h5 class="card-title">${item.itemName}</h5>
                    <p class="card-text"><small class="text-muted">${item.description}</small></p>
                    <p class="card-text">¥${item.price}</p>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </a>
      </c:forEach>
    </div> -->
      
    <!-- <c:forEach items="${items}" var="item" varStatus="status">
      <a href="/request-demo/itemDetailServlet?id=${item.id}" class="item-link">
        <div class="card" style="width: 18rem;">
          <img src="imgs/item.jpg" class="card-img-top square-img" alt="item image">
          <div class="card-body">
            <h5 class="card-title">${item.itemName}</h5>
            <p class="card-text">¥${item.price}</p>
          </div>
        </div>
      </a>
    </c:forEach> -->

    <!-- <div class="item-blank">
      <div class="item-list">
        <c:forEach items="${items}" var="item" varStatus="status">
          <div class="item">
            <a href="/request-demo/itemDetailServlet?id=${item.id}" class="item-link">
              <img src="imgs/item.jpg" class="item-img">
              <div>
                <p class="item-name">${item.itemName}</p>
                <p class="item-price">¥${item.price}</p>
              </div>
            </a>
          </div>
        </c:forEach>
      </div>
    </div> -->
  </body>
</html>